<template>
  <div class="menu-demo">
    <div class="menu">
      <a-menu
        :style="{ width: '200px', height: '100%' }"
        :default-open-keys="['0']"
        :default-selected-keys="['0_0']"
        show-collapse-button
        breakpoint="xl"
        @menu-item-click="menuItemClickHandler"
      >
        <a-sub-menu key="0">
          <template #icon><icon-book /></template>
          <template #title>文章管理</template>
          <a-menu-item key="blog">文章列表</a-menu-item>
          <a-menu-item key="tag">标签列表</a-menu-item>
          <a-menu-item key="admin">admin 测试</a-menu-item>
        </a-sub-menu>
        <a-sub-menu key="1">
          <template #icon><icon-message /></template>
          <template #title>评论管理</template>
          <a-menu-item key="comment">评论列表</a-menu-item>
        </a-sub-menu>
      </a-menu>
    </div>
    <div class="content">
      <RouterView />
    </div>
  </div>
  <div class="buttom">buttom content</div>
</template>

<script setup>
import { useRouter } from 'vue-router'
const router = useRouter()
const menuItemClickHandler = (key) => {
  router.push('/backend/' + key)
}
</script>

<style lang="css" scoped>
.backend {
  display: flex;
}
.menu-demo {
  display: flex;
  height: calc(100vh - 60px - 80px);
}
.menu {
  height: calc(100vh - 60px - 80px);
  border-right: 2px solid rgb(229, 230, 235);
}
.buttom {
  display: flex;
  height: 80px;
  width: 100%;
  align-items: center;
  justify-content: center;
  border-top: 1px solid rgb(229, 230, 235);
}
.content {
  height: 100%;
  width: 100%;
  padding: 10px;
}
</style>
